package ebuy.com.cotroller;

import ebuy.com.pojo.Easybuy_user_address;
import ebuy.com.server.Easybuy_order_detailsserver;
import ebuy.com.server.Easybuy_user_addressserver;
import ebuy.com.server.Easybuy_userserver;
import ebuy.com.server.imp.Easybuy_user_addressservermp;
import ebuy.com.util.RespBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Easybuy_user_addreCotroller {
    @Autowired
    private Easybuy_user_addressservermp easybuy_user_addressserver;
    @Autowired
    private Easybuy_userserver easybuy_userserver;
    @GetMapping("/getuse")
    //修改地址
    public RespBean UpdateEase(String uanem,String address ){
        Integer querybyusername = easybuy_userserver.Querybyusername(uanem);
        Easybuy_user_address easybuy_user_address=new Easybuy_user_address();
        easybuy_user_address.setAddress(address);
        easybuy_user_address.setUserId(querybyusername);
        easybuy_user_address.setIsDefault(1);
        int changeaddress = easybuy_user_addressserver.Changeaddress(easybuy_user_address);
        return RespBean.success("修改成功",changeaddress);
    }
    @GetMapping("/address1")
    //增加地址
    public  RespBean AddaddreSS(String name,String address){
        Integer querybyusername = easybuy_userserver.Querybyusername(name);
        Easybuy_user_address easybuy_user_address=new Easybuy_user_address();
        easybuy_user_address.setIsDefault(1);
        easybuy_user_address.setUserId(querybyusername);
        easybuy_user_address.setAddress(address);
        int addaddress = easybuy_user_addressserver.Addaddress(easybuy_user_address);
        return RespBean.success("修改成功");
    }

}
